package ruifeng.zcj.communcationring.groble;

import android.content.Context;
import android.webkit.CookieManager;
import android.webkit.CookieSyncManager;

/**
 * Created by Administrator on 2016/9/8 0008.
 */
public class Cookie {
    // 客户端通过以下代码设置cookie
    public static void synCookies(Context context, String url, String token) {
        CookieSyncManager.createInstance(context);
        CookieManager cookieManager = CookieManager.getInstance();
        cookieManager.setCookie(url, "ECT_TOKEN=" + token);
        CookieSyncManager.getInstance().sync();
    }

    /***
     * 移除所有的Cookie
     **/
    private static void removeCookie(Context context) {
        CookieSyncManager.createInstance(context);
        CookieManager cookieManager = CookieManager.getInstance();
        cookieManager.removeAllCookie();
        CookieSyncManager.getInstance().sync();
    }
}
